<template>
	<view>
		<view class="top">
			<image :src="userinfo.avatarUrl||'../../static/imgs/user.png'" mode="" class="user-img"></image>
			<view class="user-name" v-if="userinfo">
				{{userinfo.nickName}}
			</view>
			<button type="default" class="user-btn" @click="getUserProfile" v-else>点击授权登录</button>
		</view>
	</view>
</template>

<script>
	export default {
		// props:{
		// 	favlist:{
		// 		type:Object,
		// 		default:{}
		// 	}
		// },
		name:"login",
		data() {
			return {
				userinfo:null,
				favlist:{}
			};
		},
		onLaunch(){
			this.favlist=uni.getStorageSync('favlist')
			console.log('11')
			console.log(this.favlist)
			
		},
		methods:{
			getUserProfile(){
				uni.getUserProfile({
					desc:'获取个人信息'
				}).then(res=>{
					// console.log(res)
					this.userinfo=res[1].userInfo
					uni.setStorageSync('userinfo',this.userinfo)
				}).catch(err=>err)
			},

			
		},
		onLoad() {
			this.favlist=uni.getStorageSync('favlist')
			console.log('11')
			console.log(this.favlist)
			// uni.setStorageSync('favlist',this.favlist)
			this.userinfo=this.userinfo
		},
		onShow() {
			this.favlist=uni.getStorageSync('favlist')
			console.log('11')
			console.log(this.favlist)
			// uni.setStorageSync('favlist',this.favlist)
			this.userinfo=this.userinfo
		}
		
	}
</script>

<style lang="scss">
.top{
	width: 100%;
	height: 420rpx;
	background-color: #42bd56;
	display: flex;
	align-items: center;
	flex-direction: column;
	
	.user-img{
		width: 200rpx;
		height: 200rpx;
		border-radius: 50%;
		margin-top: 30rpx;
	}
	.user-name{
		color: #FFFFFF;
		margin-bottom: 10rpx;
		margin-top: 40rpx;
		font-weight: bold;
		
	}
	.user-btn{
		height: 80rpx;
		line-height: 80rpx;
		width: 400rpx;
		border-radius: 60rpx;
		margin-top: 70rpx;
		background-color: #FFFFFF;
		font-size: 30rpx;
		font-weight: bold;
	}
}

</style>
